/*
 * Copyright (c) 2022 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import {constants} from './constants.js'
"use strict";


const constants_1 = constants;
const NOOP_RUN = () => false;
const NOOP_START = () => {}; // eslint-disable-line @typescript-eslint/no-empty-function
const NOOP_END = () => {}; // eslint-disable-line @typescript-eslint/no-empty-function
class Node {
    // constructor({ run = NOOP_RUN, start = NOOP_START, end = NOOP_END, ...props }) {
    constructor({ run = NOOP_RUN, start = NOOP_START, end = NOOP_END, props }) {
        this.nodeType = 'Node';
        this.blueprint = { run, start, end, props };
        // this.blueprint = { run, start, end, ...props };
    }
    run(blackboard, { introspector, rerun = false, registryLookUp = x => x, config } = {}) {
        // run(blackboard, { introspector, rerun = false, registryLookUp = (x) => x, ...config } = {}) {
        if (!rerun) this.blueprint.start(blackboard);
        // const result = this.blueprint.run(blackboard, { ...config, rerun, registryLookUp });
        const result = this.blueprint.run(blackboard, { config, rerun, registryLookUp });
        if (result !== constants_1.RUNNING) {
            this.blueprint.end(blackboard);
        }
        if (introspector) {
            introspector.push(this, result, blackboard);
        }
        return result;
    }
    get name() {
        return this._name || this.blueprint.name;
    }
    set name(name) {
        this._name = name;
    }
}
// exports.default = Node;
export { Node }